package com.xy.job.core.api.response

fun <T> wrapperResponse(block: () -> T?): ResponseWrapper<T> {
    val result = block()
    return success(result)
}

fun <T> success(data: T?) = ResponseWrapper(
    data = data,
    success = true,
    code = ResponseCode.SUCCESS.name,
    message = "success",
)

fun <T> error(code: ResponseCode = ResponseCode.SYSTEM_ERROR, message: String? = "fail") = ResponseWrapper<T>(
    data = null,
    success = false,
    code = code.name,
    message = message ?: "",
)